﻿<Window x:Class="Freshome.m.vws.Pairaw"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:f="clr-namespace:Freshome.m.vws"
      Style="{StaticResource smaller}" MaxWidth="900" MaxHeight="600"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" WindowStartupLocation="CenterOwner">
    <Window.Resources>
        <f:Bool2Visible x:Key="b2v" />
    </Window.Resources>
    <Window.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Save" CanExecute="Save_CanExecute" Executed="Save_Executed" />
    </Window.CommandBindings>
    <Grid x:Name="topanel">
        <Grid.RowDefinitions>
            <RowDefinition></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="200"></ColumnDefinition>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
            <ColumnDefinition MinWidth="200"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <GroupBox Header="错误搭配">
            <DataGrid x:Name="dgw" ItemsSource="{Binding Path=WrongPairs}" IsReadOnly="{Binding Readonly}">
                <DataGrid.CommandBindings>
                    <CommandBinding Command="ApplicationCommands.Delete" CanExecute="Delete_CanExecute" Executed="Delete_Executed" />
                </DataGrid.CommandBindings>
                <DataGrid.ContextMenu>
                    <ContextMenu Visibility="{Binding Path=Enabled, Converter={StaticResource b2v}}">
                        <MenuItem Header="删除错误搭配" Command="ApplicationCommands.Delete"></MenuItem>
                    </ContextMenu>
                </DataGrid.ContextMenu>
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding Path=Mate}" Header="错误搭配对象" MinWidth="100" MaxWidth="200" ToolTipService.ToolTip="2 - 10个字符"/>
                    <DataGridTextColumn Binding="{Binding Path=Notes}" Header="错误搭配说明" MinWidth="200" MaxWidth="500" ToolTipService.ToolTip="0 - 50个字符"/>
                </DataGrid.Columns>
            </DataGrid>
        </GroupBox>
        <Button x:Name="btr" IsCancel="True" HorizontalAlignment="Left" Grid.Row="1">关闭(_C)</Button>
        <GridSplitter Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Width="3" VerticalAlignment="Stretch" HorizontalAlignment="Center" ShowsPreview="True"></GridSplitter>
        <GroupBox Header="正确搭配" Grid.Column="2">
            <DataGrid x:Name="dgr" ItemsSource="{Binding Path=RightPairs}" IsReadOnly="{Binding Readonly}">
                <DataGrid.CommandBindings>
                    <CommandBinding Command="ApplicationCommands.Delete" CanExecute="Delete_CanExecute" Executed="Delete_Executed" />
                </DataGrid.CommandBindings>
                <DataGrid.ContextMenu>
                    <ContextMenu Visibility="{Binding Path=Enabled, Converter={StaticResource b2v}}">
                        <MenuItem Header="删除正确搭配" Command="ApplicationCommands.Delete"></MenuItem>
                    </ContextMenu>
                </DataGrid.ContextMenu>
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding Path=Mate}" Header="正确搭配对象" MinWidth="100" MaxWidth="200" ToolTipService.ToolTip="2 - 10个字符"/>
                    <DataGridTextColumn Binding="{Binding Path=Notes}" Header="正确搭配说明" MinWidth="200" MaxWidth="500" ToolTipService.ToolTip="0 - 50个字符"/>
                </DataGrid.Columns>
            </DataGrid>
        </GroupBox>
        <Button Grid.Row="1" Grid.Column="2" HorizontalAlignment="Right" Command="ApplicationCommands.Save" 
                Visibility="{Binding Path=Enabled, Converter={StaticResource b2v}}">保存(_S)</Button>
    </Grid>
</Window>
